<?php 
$danhmucs = $viewModel->get('danhmucs');    
$tinhthanhs = $viewModel->get('tinhthanhs'); 
$baiviets = $viewModel->get('baiviet');  
?>
      <div class="container-fluid" style="width:97%">
      <form class="form-horizontal" method="POST">
        <div class="row top-page">
          <div class="col-xs-12 col-md-6">
              <h1><span class="glyphicon glyphicon-map-marker"></span> Bài viết: Cập nhật bài viết<span class="glyphicon glyphicon-plus-sign"></span></h1>
          </div>
           <div class="col-xs-12 col-md-6 save">
              <button type="submit" class="btn btn-primary btn1">
                <span class="glyphicon glyphicon-floppy-disk"></span>
               Lưu bài viết</button>      
              <a href="<?php echo BASE_URL.'baiviet' ?>" class="btn btn-success btn1">
                <span class="glyphicon glyphicon-arrow-left"></span> Quay lại </a>
          </div>
        </div>
        <div class="row title1">
          <div class="col-xs-12 col-md-8">
            <div class="form-group">
                <h2 class="col-sm-2 control-label">Tên bài viết</h2>
                 <input type="hidden" class="form-control" name="id" value="<?php echo $baiviets->Id ?>">  
                <input type="hidden" class="form-control" name="tukhoadanhmuc" value="<?php echo $danhmucs->TuKhoaDanhMuc ?>">  
                <div class="col-sm-10">
                    <input type="text" class="form-control input1" name="tenbaiviet" id="inputEmail3" value="<?php echo $baiviets->TieuDe; ?>" placeholder="Tên bài viết" required>
                    <?php if (!empty($NameError)): ?>
                      <span class="help-inline"><?php echo $NameError;?></span>
                    <?php endif; ?>
                </div>
              </div>
          </div>
          <div class="col-xs-12 col-md-4">
               <h2 class="col-sm-2 control-label">Alias</h2>
                <div class="col-sm-10">
                    <input type="text" class="form-control input1" name="alias" id="inputEmail3"  value="<?php echo $baiviets->DuongDan; ?>" placeholder="Alias sinh tự động">
                    <?php if (!empty($NameError)): ?>
                      <span class="help-inline"><?php echo $NameError;?></span>
                    <?php endif; ?>
                </div>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-12 col-md-9">  
             <ul class="nav nav-tabs" role="tablist" id="myTab">
                <li class="active"><a href="#home" role="tab" data-toggle="tab">Nội dung</a></li>
              </ul>

              <div class="tab-content">
                <div class="tab-pane active" id="home">
                  <textarea name="noidung" class="ckeditor" placeholder="Nhập bài viết"  
                    rows="10"><?php echo $baiviets->NoiDung; ?></textarea> 
                    <?php if (!empty($ContentError)): ?>
                      <span class="help-inline"><?php echo $ContentError;?></span>
                    <?php endif; ?>  
                </div>
            </div>
              <script>
                $(function () {
                  $('#myTab a:last').tab('show')
                })
              </script>
              <div class="form-group">
                    <div class="col-sm-10">
                        <h2 class="title2">Chọn hình ảnh đại diện</h2>
                        <div class="row">
                          <input type="text" value="<?php echo $baiviets->AnhThumb; ?>" id="Image" style="width:42%; float:left; margin-left: 10px;" class="form-control" name="hinhanh" id="inputEmail3" placeholder="Chọn hình ảnh thumb"  value="<?php echo $baiviets->AnhThumb; ?>">                      
                          <input type="button" id="BrowseImageIcon" style="width:20%; float:left" class="btn btn-success btn1" value="Duyệt ảnh" />
                        </div>
                         <h2 class="title2">Link clip Youtube</h2>
                        <div class="row">
                          <input type="text" value="<?php echo $baiviets->Clip; ?>" id="clip" style="width:42%; float:left; margin-left: 10px;" class="form-control" name="clip">                      
                        </div>
                        <hr>
                    </div>
              </div>
            </div>
           <div class="col-xs-12 col-md-3">
            <h2 class="zone_title">Thông tin bài viết</h2>
           <h2 class="title2">Danh mục bài viết</h2>
             <select name="TenDanhMuc" class="form-control">
                       <?php foreach ($danhmucs as $danhmuc) { ?> 
                            <option <?php if($baiviets->TuKhoaDanhMuc==$danhmuc->TuKhoaDanhMuc)
                            {echo 'selected="selected"';} ?> value="<?php echo $danhmuc->TuKhoaDanhMuc; ?>">
                            <?php echo $danhmuc->TenDanhMuc; ?></option>    
                       <?php } ?>
            </select>   
          
           <h2 class="title2">Tỉnh thành</h2>
             <select name="tinhthanh" class="form-control">
                       <?php foreach ($tinhthanhs as $tinhthanh) { ?> 
                            <option <?php if($baiviets->TuKhoaTinhThanh==$tinhthanh->TuKhoa)
                            {echo 'selected="selected"';} ?> value="<?php echo $tinhthanh->TuKhoa; ?>">
                            <?php echo $tinhthanh->TenTinh; ?></option>    
                       <?php } ?>
            </select>  
            <h2 class="title2">Mô tả</h2>
            <input type="text" class="form-control" name="mota" id="inputEmail3" placeholder="Mô tả"  value="<?php echo $baiviets->MoTa; ?>" required>            
            <h2 class="title2">Tình trạng</h2>
              <select name="tinhtrang" class="form-control" value="<?php echo $baiviets->TinhTrang; ?>">                                                                       
                          <option value="Hoạt động">Hoạt động</option>   
                          <option value="Khóa">Khóa</option>                        
              </select>
               <h2 class="title2">Từ khóa địa điểm</h2>
              <input type="text" class="form-control" value="<?php echo $baiviets->TuKhoaDiaDiem; ?>" name="tukhoadiadiem" id="inputEmail3">
              <h2 class="title2">Từ khóa tỉnh thành</h2>
              <input type="text" class="form-control" value="<?php echo $baiviets->TuKhoaTinhThanh; ?>" name="tukhoatinhthanh" id="inputEmail3">
          </div>
        </div>  
        </form>
      </div>
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
   
    